/**
 * <pre>
 * @(#)Position.java 1.00 2009-8-27
 * 
 * Copyright (c) 1998, 2009 Regular Individual. All rights reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *    http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 * Contributor(s):
 *     Haixu Huang
 * </pre>
 **/
package cn.sh.huang.chart.ext.enumtype;

/**
 * <pre>
 * Position ...
 * 
 * @version 1.0
 * </pre>
 */
final public class Position
{
    private final Side[] corner;

    private Position(Side[] corner)
    {
        this.corner = corner;
    }

    public boolean onTheSide(Side side)
    {
        return corner[0].equals(side) || corner[1].equals(side);
    }

    public int[] code()
    {
        return new int[] { corner[0].code(), corner[1].code() };
    }

    /**
     * <code>
     * +--------------------+----------------------+---------------------+
     * |   LEFT_TOP [0, 0]  |   CENTER_TOP [1, 0]  |   RIGHT_TOP [2, 0]  |
     * +--------------------+----------------------+---------------------+
     * | LEFT_CENTER [0, 1] |      CORE [1, 1]     | RIGHT_CENTER [2, 1] |
     * +--------------------+----------------------+---------------------+
     * | LEFT_BOTTOM [0, 2] | CENTER_BOTTOM [1, 2] | RIGHT_BOTTOM [2, 2] |
     * +--------------------+----------------------+---------------------+
     * </code>
     */
    public static final Position
            LEFT_TOP = new Position(new Side[] { Side.LEFT, Side.TOP, }),
            CENTER_TOP = new Position(new Side[] { Side.CENTER, Side.TOP, }),
            RIGHT_TOP = new Position(new Side[] { Side.RIGHT, Side.TOP, }),
            LEFT_CENTER = new Position(new Side[] { Side.LEFT, Side.CENTER, }),
            CORE = new Position(new Side[] { Side.CENTER, Side.CENTER, }),
            RIGHT_CENTER = new Position(new Side[] { Side.RIGHT, Side.CENTER, }),
            LEFT_BOTTOM = new Position(new Side[] { Side.LEFT, Side.BOTTOM, }),
            CENTER_BOTTOM = new Position(new Side[] { Side.CENTER, Side.BOTTOM, }),
            RIGHT_BOTTOM = new Position(new Side[] { Side.RIGHT, Side.BOTTOM, });
}
